#!/usr/local/bin/perl -w

#  
#     Zhejiang tianke
#     Author: Shangao
#     version 0.1
#     date: 2012-12-04
#     License: GPL
#     
#     Summary:
#     This script qulity and filter the raw fastq file 
#     and clean and trim the raw data 

use strict;
use warnings;

if(@ARGV<1){
    print "usage\t<fastq file>\n";
    exit;
}

my $input_file=shift;
my $input_file_1=$input_file."_m50";
my $input_file_2=$input_file_1."_trim10-500";
my $input_file_3=$input_file_2."_Qual20";
my $input_file_4=$input_file_3.".QATrimer.fastq";

my $fastx_clipper_command="nohup fastx_clipper -i ".$input_file." -o ".$input_file_1." -l 50 -Q 33 -v";
my $fastx_trimmer_command="nohup fastx_trimmer -i ".$input_file_1." -o ".$input_file_2." -f 11 -l 500 -m 50 -Q 33 -v";
my $fastq_quality_filter_command="nohup  fastq_quality_filter -i ".$input_file_2." -o ".$input_file_3." -q 20 -p 80 -Q 33 -v";
my $fastq_quality_trimmer_command="nohup fastq_quality_trimmer -t 20 -l 40 -Q 33 -i ".$input_file_3." -o ".$input_file_4;
system($fastx_clipper_command);
system($fastx_trimmer_command);
system("rm $input_file_1");
system($fastq_quality_filter_command);
system("rm $input_file_2");
system($fastq_quality_trimmer_command);
system("rm $input_file_3");
